package com.zxy.basic;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author liuyang
 */
@Slf4j
@SpringBootApplication
@EnableConfigurationProperties
@MapperScan("com.zxy.basic.dao")
public class Application {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = null;
        try {
            application = SpringApplication.run(Application.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Environment env = application.getEnvironment();
        String host = InetAddress.getLocalHost()
                                 .getHostAddress();
        String port = env.getProperty("server.port");
        log.info("\n----------------------------------------------------------\n\t" +
                         "应用 '{}' 运行成功! \n\t" +
                         "Server Port: \t\t{}\n\t" +
                         "Swagger文档: \t\thttp://{}:{}/swagger-ui.html\n" +
                         "----------------------------------------------------------",
                 env.getProperty("spring.application.name"),
                 port, host, port);
    }

}
